<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网页设计3</title>
</head>
<script>
    window.onload = function(){

       var btn = document.getElementById('btn');
       btn.onclick =function(){
        var i;
       var sum = 0;
       for(i=1;i<=100;i++){
        sum+=i;
       } 
        document.write("1+2+3+...+100="+sum);
       }
    }
</script>
<body>
    <input type = "button" value="计算1+2+3+...+100的累计和" id= "btn">
</body>
</html>